var headObj={
	inits:function(){
		this.searchFun();
		this.ajax();
		this.headPicFun();
		$(".content").css("minHeight",document.documentElement.clientHeight -251)
	},
	Interface:{
		isLogin:"http://ww.yc630.com/api/index.php/Buyer/Login/isLogin",  //是否登录
		isSeller:"http://ww.yc630.com/api/index.php/Seller/Seller/isSeller"//判断买卖家 0 是卖家  1非卖家

	},
	ajax:function(){
		//console.log(headObj.Interface.isLogin)
		common.ajaxFun(headObj.Interface.isLogin,"POST",{token:token},headObj.isLoginFun); //是否登录
	},
	searchFun:function(){
		$("#searchBtn").click(function(){
			var searchtype=$(this).siblings("select").val(),
				searchkey=$(this).siblings("input").val();
				//console.log(searchkey)
			window.location.href="./CommoditySearch.html?searchtype="+searchtype+"&searchkey="+escape(searchkey);
		});
	},
	isLoginFun:function(res){
		if (res.code==0) {
			$("#headPic").show();
			$(".loginOrRe").hide();
			$("#headPic").attr("src",res.data.avatar);
		}else {
			$("#headPic").hide();
			$(".loginOrRe").show();
			common.removeCookie("token");
		};
	},
	headPicFun:function(){
		
		$("#headPic").on("click",function(){
		common.ajaxFun(headObj.Interface.isSeller,"POST",{token:token},function(res){
			if (res.code==0) {
				if (common.getCookie("flag")!="") {
					if (common.getCookie("flag")==0) {//到买家
						window.location.href="./../page/ddlb.html";
						common.setCookie("flag",1);
					}else if (common.getCookie("flag")==1) {//到卖家
						window.location.href="./../page/goods_house.html";
						common.setCookie("flag",0);
					};
				}else if(common.getCookie("flag")=="") {
					common.setCookie("flag",0);
					window.location.href="./../page/goods_house.html";
				};
			}else if (res.code==1){
				window.location.href="./../page/ddlb.html";
			};
			
		}); //判断买卖家 0 是卖家  1非卖家

			
		});
			
	}
}
headObj.inits()